var a = require("../../utils/api.js"), t = getApp(), e = require("../../wxParse/wxParse.js");

Page({
    data: {
        current: 0,
        swiperItem: [],
        money: [],
        showLoding: !0
    },
    onLoad: function(n) {
        var o = this;
        o.setData({
            showLoding: !1
        }), a.markrting({
            op: "recharge_config",
            openid: t.globalData.openid
        }).then(function(a) {
            console.log(a);
            for (var t = [], n = 0; n < a.data.data.info.length; n++) {
                var i = {
                    money: a.data.data.info[n].money,
                    id: a.data.data.info[n].id
                };
                t.push(i);
            }
            o.setData({
                swiperItem: a.data.data.info,
                money: t,
                showLoding: !0
            }), e.wxParse("article", "html", a.data.data.info[0].content, o, 5);
        });
    },
    change: function(a) {
        console.log(a);
        var t = a.detail.current, n = this;
        n.setData({
            current: t
        }), e.wxParse("article", "html", n.data.swiperItem[t].content, n, 5);
    },
    slider: function(a) {},
    recharge: function(e) {
        wx.showLoading({
            title: "加载中..."
        });
        var n = e.currentTarget.dataset.id;
        a.markrting({
            op: "recharge_pay",
            openid: t.globalData.openid,
            id: n
        }).then(function(e) {
            wx.hideLoading(), console.log(e), 0 == e.code ? wx.requestPayment({
                timeStamp: e.data.data.timeStamp,
                nonceStr: e.data.data.nonceStr,
                package: e.data.data.package,
                signType: "MD5",
                paySign: e.data.data.paySign,
                success: function(n) {
                    wx.showToast({
                        title: "支付成功",
                        icon: "none",
                        duration: 2e3
                    }), a.markrting({
                        op: "recharge_pay_callback",
                        openid: t.globalData.openid,
                        id: e.data.data.id
                    }).then(function(a) {
                        console.log(a), wx.navigateBack({
                            delta: 1
                        });
                    });
                },
                fail: function() {
                    wx.showToast({
                        title: "支付失败",
                        icon: "none",
                        duration: 2e3
                    });
                }
            }) : 0 != e.code && wx.hideLoading();
        });
    }
});